package main

import (
	"fmt"
	//"strings"
)

type node struct {
	nValue int
	pNext *node
}

type linkedlist struct {
	pHead *node
	pTail *node
	nSize int
}

func (pll *linkedlist) init() {
	pll.pHead = new(node)
	pll.pHead.nValue = 0
	pll.pHead.pNext = nil
	
	pll.pTail = pll.pHead
	
	pll.nSize = 0
}

func (pll *linkedlist) push_back(nValue int) int {
	nRt := 0
	
	var pNode *node = new(node)
	pNode.nValue = nValue
	pNode.pNext = nil
	
	pll.pTail.pNext = pNode
	
	pll.pTail = pNode
	
	pll.nSize++
	
	return nRt
}

func (pll *linkedlist) Size() int {
	return pll.nSize
}

func (pll *linkedlist) Show() {
	if pll.pHead.pNext == nil {
		return
	}
	
	var pTemp *node = pll.pHead.pNext
	for pTemp != nil {
		println(pTemp.nValue)
		pTemp = pTemp.pNext
	}
}

const (
	a = 3
)

func foo(str string) int {
	return len(str)
}

func newstr(str string) *string {

	arr := []byte(str)
	s := make([]byte, 0)
	for i := 0; i < len(arr); i++ {
		s = append(s, arr[i])
		s = append(s, ' ')
	}
	
	var sRt *string= new(string)
	*sRt = string(s)
	
	return sRt
}

func main() {
	
	//var t int = 3
	var arr[10] int
	s1 := arr[:]
	s2 := make([]int, 10)
	
	for i := 0; i < 10; i++ {
		arr[i] = i
		fmt.Printf("%d\n", arr[i])
	}
	
	for i := 0; i < 10; i++ {
		s1 = append(s1, i)
	} 
	
	md := make(map[string]int)
	md["jav"] = 31
	md["feb"] = 29
	
	var p bool
	var v int
	v, p = md["jav"]
	
	if p == true{
		fmt.Printf("%v\n",v)
	}
	
	fmt.Printf("%v:%v\n", len(s2), len(s1))
	fmt.Printf("%v\n", md["feb"])
	fmt.Println(foo("wefewf"))
	
	//var str *string  
	
	fmt.Println(*newstr("hello"))
	
	var pll *linkedlist = new(linkedlist)
	pll.init()
	pll.push_back(19)
	pll.push_back(1)
	pll.push_back(9)
	pll.push_back(193)
	pll.push_back(194)
	pll.push_back(196)
	
	fmt.Printf("size:%d\n", pll.Size())
	pll.Show()
}
